package org.dce.screencapturer.actions.drawing;

import java.awt.event.ActionEvent;

import javax.swing.Icon;

import org.dce.screencapturer.Drawing;
import org.dce.screencapturer.actions.DrawingAction;
import org.dce.screencapturer.objects.DrawingObject;

public class InsertObjectAction 
	extends DrawingAction{

	private static final long serialVersionUID = -2470540899488583714L;
	
	private Class<? extends DrawingObject> objectClass;

	public InsertObjectAction(String actionId,Icon icon,Drawing drawing,Class<? extends DrawingObject> objectClass){
		super("categories.draw",actionId,icon);
		setDrawing(drawing);
		this.objectClass = objectClass;
	}
	
	public DrawingObject getInsertedObject(){
		try {
			return objectClass.newInstance();
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}
	}
	
	public void actionPerformed(ActionEvent event){
		getDrawing().startInsertion(this);
	}
	
}
